libxc: convert schedop interfaces over to hypercall buffers
authorIan Campbell <ian.campbell@citrix.com>
Fri, 22 Oct 2010 14:14:51 +0000 (15:14 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 22 Oct 2010 14:14:51 +0000 (15:14 +0100)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson.citrix.com>
tools/libxc/xc_domain.c

index e41f773745e2d6e4c100876d4dab614b2fb690ae..df33f4d5c6c2f857aac6b237e4c4e5cd2366c620 100644 (file)
@@ -85,24 +85,25 @@ int xc_domain_shutdown(xc_interface *xch,
                        int reason)
 {
     int ret = -1;
-    sched_remote_shutdown_t arg;
     DECLARE_HYPERCALL;
+    DECLARE_HYPERCALL_BUFFER(sched_remote_shutdown_t, arg);
 
-    hypercall.op     = __HYPERVISOR_sched_op;
-    hypercall.arg[0] = (unsigned long)SCHEDOP_remote_shutdown;
-    hypercall.arg[1] = (unsigned long)&arg;
-    arg.domain_id = domid;
-    arg.reason = reason;
-
-    if ( lock_pages(xch, &arg, sizeof(arg)) != 0 )
+    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
+    if ( arg == NULL )
     {
-        PERROR("Could not lock memory for Xen hypercall");
+        PERROR("Could not allocate memory for xc_domain_shutdown hypercall");
         goto out1;
     }
 
+    hypercall.op     = __HYPERVISOR_sched_op;
+    hypercall.arg[0] = (unsigned long)SCHEDOP_remote_shutdown;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+    arg->domain_id = domid;
+    arg->reason = reason;
+
     ret = do_xen_hypercall(xch, &hypercall);
 
-    unlock_pages(xch, &arg, sizeof(arg));
+    xc_hypercall_buffer_free(xch, arg);
 
  out1:
     return ret;